/*
 * ktz8866.h - ktz8866 LEDs Driver
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
#ifndef __KTZ8866_H__
#define __KTZ8866_H__

struct device;

struct ktz8866_platform_data {
	struct device *fbdev;
	int hw_en_gpio;
	int enp_gpio;
	int enn_gpio;
};

/* KTZ8866 backlight I2C driver */
#define KTZ8866_backlight_EN_MASK         0x40
#define KTZ8866_backlight_EN_SHIFT        6
#define KTZ8866_backlight_DISABLE         0
#define KTZ8866_backlight_ENABLE          1
#define KTZ8866_LCD_BIAS_ENP              130       //GPIO for Enable pin for positive power (OUTP)
#define KTZ8866_LCD_BIAS_ENN              131       //GPIO for Enable pin for negative power (OUTN)
#define KTZ8866_LCD_DRV_HW_EN             139       //GPIO for Active high hardware enable pin
#define KTZ8866_LCD_DRV_I2C_SCL           61       //Clock of the I 2 C interface.
#define KTZ8866_LCD_DRV_I2C_SDA           60       //Bi-directional data pin of the I 2 C interface.
#define KTZ8866_DISP_ID                   0x01
#define KTZ8866_DISP_BC1                  0x02
#define KTZ8866_DISP_BC2                  0x03
#define KTZ8866_DISP_BB_LSB               0x04
#define KTZ8866_DISP_BB_MSB               0x05
#define KTZ8866_DISP_BL_ENABLE            0x08
#define KTZ8866_DISP_BIAS_CONF1           0x09
#define KTZ8866_DISP_BIAS_CONF2           0x0a
#define KTZ8866_DISP_BIAS_CONF3           0x0b
#define KTZ8866_DISP_BIAS_BOOST           0x0c
#define KTZ8866_DISP_BIAS_VPOS            0x0d
#define KTZ8866_DISP_BIAS_VNEG            0x0e
#define KTZ8866_DISP_FLAGS                0x0f
#define KTZ8866_DISP_OPTION1              0x10
#define KTZ8866_DISP_OPTION2              0x11
#define KTZ8866_DISP_PTD_LSB              0x12
#define KTZ8866_DISP_PTD_MSB              0x13
#define KTZ8866_DISP_DIMMING              0x14
#define KTZ8866_DISP_FULL_CURRENT         0x15
#define BL_LEVEL_MAX 2047

struct ktz8866_reg {
	unsigned char reg;
	unsigned char value;
};

/**
 * struct ktz8866_led -
 * @lock - Lock for reading/writing the device
 * @level - setting backlight level
 * @level - setting backlight status
**/
struct ktz8866_led {
		struct mutex lock;
		int level;
		bool ktz8866_status;
		bool dimming_status;
};

static struct ktz8866_reg ktz8866_regs_conf[] = {
	{ KTZ8866_DISP_BB_LSB, 0x01 },/* LSB: limit I2C code 1009 DBV level*/
	{ KTZ8866_DISP_BB_MSB, 0x7E },/* MSB: limit I2C code 1009 DBV level*/
	{ KTZ8866_DISP_BC1, 0x33 },/* Backlight OVP 26.4V, exponential mapping*/
	{ KTZ8866_DISP_FULL_CURRENT, 0xb1 },/* Backlight Full-scale LED Current 23mA*/
	{ KTZ8866_DISP_BC2, 0xbd },/* LED ramping time 128ms*/
	{ KTZ8866_DISP_DIMMING, 0x11 },/* LED on/off ramping time 1ms*/
	{ KTZ8866_DISP_BIAS_CONF1, 0x9f },/* OUTP and OUTN enabled via pin ENP and ENN*/
	{ KTZ8866_DISP_BL_ENABLE, 0x5f },/* KTZ8866_DISP_BL_ENABLE BL_EN*/
};

static const int bl_level_remap[BL_LEVEL_MAX+1] = {
0,17,17,31,40,54,107,132,163,186,
213,222,241,260,279,300,321,330,349,365,
379,395,408,419,430,440,449,458,466,485,
507,525,540,558,573,583,594,607,621,635,
646,659,669,676,681,690,703,711,720,728,
738,746,751,759,768,775,783,789,797,804,
810,815,821,830,835,842,847,852,859,862,
868,874,879,886,891,897,902,911,916,921,
926,930,936,940,944,948,952,957,962,966,
970,974,978,980,984,988,992,996,1000,1004,
1008,1011,1014,1018,1022,1025,1029,1032,1035,1038,
1040,1041,1044,1048,1051,1054,1057,1061,1063,1065,
1068,1071,1075,1078,1081,1084,1087,1090,1091,1094,
1096,1099,1102,1105,1107,1108,1111,1114,1117,1120,
1122,1124,1127,1130,1132,1135,1138,1140,1142,1146,
1148,1151,1153,1154,1156,1159,1161,1163,1165,1168,
1170,1172,1173,1176,1178,1180,1182,1185,1187,1189,
1190,1193,1195,1197,1199,1202,1204,1206,1208,1209,
1211,1213,1215,1217,1219,1221,1222,1224,1225,1227,
1228,1230,1232,1234,1236,1237,1238,1240,1242,1243,
1245,1247,1249,1251,1252,1253,1255,1256,1258,1260,
1262,1263,1265,1268,1270,1272,1274,1275,1276,1279,
1280,1282,1283,1284,1286,1287,1289,1290,1292,1293,
1294,1296,1297,1299,1300,1302,1303,1304,1305,1307,
1308,1310,1311,1313,1314,1316,1317,1318,1319,1321,
1322,1323,1325,1326,1328,1329,1330,1332,1334,1335,
1337,1338,1339,1341,1342,1343,1345,1346,1347,1348,
1349,1351,1352,1353,1354,1355,1356,1357,1358,1360,
1361,1362,1363,1364,1365,1366,1367,1368,1369,1370,
1371,1373,1374,1375,1376,1377,1378,1379,1380,1381,
1382,1383,1384,1385,1387,1388,1389,1390,1391,1392,
1393,1395,1396,1397,1398,1399,1400,1401,1402,1403,
1404,1405,1406,1407,1408,1409,1410,1411,1412,1413,
1414,1415,1416,1417,1418,1419,1420,1421,1422,1423,
1424,1425,1426,1427,1428,1429,1430,1431,1432,1433,
1434,1435,1436,1437,1438,1439,1440,1441,1442,1443,
1444,1445,1446,1447,1448,1449,1450,1451,1452,1453,
1454,1455,1456,1457,1457,1458,1459,1460,1461,1462,
1463,1464,1465,1466,1467,1467,1468,1469,1470,1471,
1471,1472,1473,1473,1474,1475,1476,1477,1478,1479,
1480,1481,1481,1482,1483,1484,1484,1485,1486,1487,
1488,1489,1490,1490,1491,1492,1493,1494,1495,1496,
1497,1498,1499,1500,1501,1502,1503,1504,1505,1506,
1507,1508,1509,1510,1511,1512,1513,1514,1515,1516,
1517,1518,1519,1520,1521,1522,1523,1524,1524,1524,
1524,1524,1524,1524,1524,1525,1526,1527,1528,1529,
1530,1531,1532,1533,1534,1535,1536,1537,1538,1539,
1540,1541,1542,1543,1544,1545,1546,1547,1548,1549,
1550,1551,1552,1552,1552,1552,1552,1552,1552,1552,
1552,1552,1552,1552,1552,1553,1554,1554,1555,1556,
1556,1557,1557,1558,1559,1559,1560,1561,1562,1562,
1563,1564,1564,1565,1565,1566,1566,1567,1567,1567,
1568,1569,1569,1570,1571,1572,1572,1573,1574,1574,
1575,1575,1576,1577,1578,1578,1579,1580,1581,1582,
1583,1584,1585,1585,1586,1586,1587,1587,1588,1588,
1588,1588,1589,1589,1589,1589,1590,1590,1590,1590,
1591,1592,1593,1593,1594,1595,1596,1596,1597,1597,
1598,1598,1599,1599,1600,1600,1601,1602,1603,1603,
1604,1604,1605,1605,1606,1606,1607,1607,1608,1608,
1609,1609,1610,1610,1611,1611,1612,1612,1613,1613,
1614,1615,1615,1616,1617,1617,1618,1618,1619,1619,
1620,1620,1621,1621,1622,1622,1623,1624,1625,1626,
1627,1627,1628,1628,1629,1629,1630,1630,1631,1631,
1632,1632,1633,1633,1634,1634,1635,1635,1636,1636,
1637,1638,1638,1639,1640,1640,1641,1641,1642,1642,
1643,1643,1644,1644,1645,1645,1646,1647,1647,1648,
1648,1649,1649,1650,1650,1651,1651,1652,1653,1653,
1654,1654,1655,1656,1656,1657,1657,1658,1658,1659,
1659,1660,1660,1661,1662,1662,1663,1663,1664,1664,
1664,1665,1665,1665,1666,1666,1667,1667,1668,1668,
1669,1669,1670,1670,1671,1671,1672,1672,1673,1673,
1674,1674,1675,1675,1676,1676,1676,1677,1677,1678,
1678,1679,1679,1679,1680,1680,1681,1681,1682,1682,
1683,1683,1684,1684,1685,1685,1686,1686,1686,1686,
1687,1687,1687,1688,1688,1689,1689,1690,1690,1691,
1692,1693,1693,1694,1694,1695,1695,1696,1696,1697,
1697,1698,1698,1699,1699,1700,1700,1701,1701,1701,
1702,1702,1702,1703,1703,1704,1704,1705,1705,1706,
1706,1707,1707,1708,1708,1709,1709,1710,1710,1710,
1711,1711,1711,1712,1712,1713,1713,1714,1714,1715,
1715,1716,1716,1717,1717,1718,1718,1719,1719,1720,
1720,1721,1721,1722,1722,1723,1723,1724,1724,1724,
1724,1725,1725,1725,1726,1726,1726,1727,1727,1728,
1728,1729,1729,1730,1730,1730,1731,1731,1732,1732,
1732,1733,1733,1733,1734,1734,1734,1735,1735,1736,
1736,1736,1736,1737,1737,1738,1738,1739,1739,1739,
1740,1740,1740,1741,1741,1741,1742,1742,1743,1743,
1743,1744,1744,1744,1745,1745,1746,1747,1747,1748,
1748,1749,1749,1749,1750,1750,1751,1751,1751,1752,
1752,1752,1752,1753,1753,1754,1754,1755,1755,1756,
1756,1756,1757,1757,1757,1758,1758,1759,1759,1760,
1760,1761,1761,1761,1762,1762,1762,1763,1763,1763,
1764,1764,1765,1765,1765,1766,1766,1766,1766,1767,
1767,1767,1767,1768,1768,1769,1769,1770,1770,1770,
1771,1771,1771,1772,1772,1772,1773,1773,1773,1774,
1774,1775,1775,1776,1776,1776,1776,1777,1777,1777,
1778,1778,1778,1779,1779,1779,1780,1780,1781,1781,
1782,1782,1782,1783,1783,1784,1784,1784,1785,1785,
1786,1786,1787,1787,1788,1788,1789,1789,1789,1789,
1790,1790,1791,1791,1792,1792,1792,1792,1793,1793,
1793,1793,1794,1794,1794,1794,1795,1795,1796,1796,
1796,1797,1797,1798,1798,1799,1799,1799,1800,1800,
1800,1800,1801,1801,1801,1801,1802,1802,1802,1803,
1803,1804,1804,1804,1805,1805,1805,1805,1806,1806,
1806,1806,1807,1807,1807,1807,1808,1808,1809,1809,
1810,1810,1810,1810,1811,1811,1811,1811,1812,1812,
1813,1813,1814,1814,1814,1814,1815,1815,1815,1815,
1815,1815,1816,1816,1816,1816,1816,1816,1816,1816,
1816,1816,1817,1817,1817,1817,1818,1818,1818,1818,
1819,1819,1819,1819,1820,1820,1820,1820,1821,1821,
1822,1822,1822,1823,1823,1823,1824,1824,1824,1824,
1825,1825,1825,1825,1826,1826,1826,1826,1827,1827,
1828,1828,1829,1829,1829,1829,1830,1830,1830,1831,
1831,1832,1832,1832,1833,1833,1833,1833,1834,1834,
1834,1835,1835,1835,1836,1836,1837,1837,1837,1837,
1838,1838,1838,1838,1839,1839,1840,1840,1841,1841,
1841,1841,1842,1842,1842,1842,1843,1843,1843,1843,
1844,1844,1845,1845,1846,1846,1846,1846,1847,1847,
1847,1848,1848,1849,1849,1849,1850,1850,1850,1850,
1850,1851,1851,1851,1851,1852,1852,1852,1853,1853,
1854,1854,1854,1855,1855,1855,1855,1856,1856,1856,
1856,1857,1857,1857,1857,1858,1858,1858,1858,1859,
1859,1859,1859,1860,1860,1861,1861,1862,1862,1862,
1862,1863,1863,1863,1863,1864,1864,1864,1864,1865,
1865,1865,1865,1866,1866,1866,1866,1867,1867,1867,
1867,1868,1868,1868,1868,1869,1869,1869,1869,1870,
1870,1870,1870,1871,1871,1871,1871,1872,1872,1873,
1873,1874,1874,1874,1874,1875,1875,1875,1875,1876,
1876,1876,1876,1877,1877,1877,1877,1878,1878,1878,
1878,1879,1879,1880,1880,1881,1881,1881,1881,1882,
1882,1882,1882,1883,1883,1883,1883,1884,1884,1884,
1884,1885,1885,1885,1885,1886,1886,1886,1886,1887,
1887,1887,1887,1888,1888,1888,1888,1889,1889,1889,
1889,1890,1890,1890,1890,1891,1891,1891,1891,1892,
1892,1892,1893,1893,1893,1894,1894,1895,1895,1895,
1895,1896,1896,1896,1896,1897,1897,1897,1897,1898,
1898,1898,1898,1899,1899,1899,1899,1900,1900,1900,
1900,1901,1901,1901,1901,1902,1902,1902,1902,1903,
1903,1903,1904,1904,1904,1905,1905,1906,1906,1906,
1906,1907,1907,1907,1907,1908,1908,1908,1908,1909,
1909,1909,1909,1910,1910,1910,1910,1911,1911,1911,
1912,1912,1913,1913,1913,1914,1914,1914,1914,1914,
1915,1915,1915,1915,1916,1916,1916,1916,1917,1917,
1917,1917,1918,1918,1918,1918,1919,1919,1919,1919,
1920,1920,1920,1920,1921,1921,1921,1921,1922,1922,
1922,1922,1923,1923,1923,1923,1924,1924,1924,1924,
1925,1925,1925,1925,1925,1925,1925,1925,1926,1926,
1926,1926,1927,1927,1927,1927,1928,1928,1928,1928,
1929,1929,1929,1929,1930,1930,1930,1930,1931,1931,
1931,1931,1932,1932,1932,1932,1933,1933,1933,1933,
1934,1934,1934,1934,1935,1935,1935,1935,1935,1935,
1935,1935,1936,1936,1936,1936,1937,1937,1937,1937,
1938,1938,1938,1939,1939,1939,1939,1939,1940,1940,
1940,1940,1941,1941,1941,1941,1942,1942,1942,1942,
1943,1943,1943,1943,1944,1944,1944,1944,1945,1945,
1945,1945,1946,1946,1946,1946,1947,1947,1947,1947,
1948,1948,1948,1948,1949,1949,1949,1949,1950,1950,
1950,1950,1950,1950,1950,1950,1951,1951,1951,1951,
1952,1952,1952,1952,1952,1952,1952,1952,1953,1953,
1953,1953,1954,1954,1954,1954,1955,1955,1955,1955,
1956,1956,1956,1956,1957,1957,1957,1957,1958,1958,
1958,1958,1959,1959,1959,1959,1960,1960,1960,1960,
1961,1961,1961,1961,1962,1962,1962,1962,1962,1962,
1962,1962,1963,1963,1963,1963,1964,1964,1964,1964,
1965,1965,1965,1965,1965,1966,1966,1966,1966,1967,
1967,1967,1967,1968,1968,1968,1968,1969,1969,1969,
1969,1970,1970,1970,1970,1971,1971,1971,1971,1972,
1972,1972,1972,1973,1973,1973,1973,1974,1974,1974,
1974,1975,1975,1975,1975,1976,1976,1976,1976,1977,
1977,1977,1977,1978,1978,1978,1978,1979,1979,1979,
1979,1980,1980,1980,1980,1981,1981,1981,1981,1982,
1982,1982,1982,1983,1983,1983,1983,1983,1983,1983,
1983,1984,1984,1984,1984,1985,1985,1985,1985,1986,
1986,1986,1986,1986,1986,1986,1986,1987,1987,1987,
1987,1988,1988,1988,1988,1989,1989,1989,1989,1989,
1989,1989,1989,1990,1990,1990,1990,1991,1991,1991,
1991,1992,1992,1992,1992,1993,1993,1993,1993,1993,
1993,1993,1993,1993,1993,1993,1993,1995,1995,1995,
1995,1996,1996,1996,1996,1996,1996,1996,1996,1997,
1997,1997,1997,1998,1998,1998,1998,1999,1999,1999,
1999,1999,1999,1999,1999,2000,2000,2000,2000,2001,
2001,2001,2001,2002,2002,2002,2002,2002,2002,2002,
2002,2003,2003,2003,2003,2004,2004,2004,2004,2004,
2004,2004,2004,2005,2005,2005,2005,2006,2006,2006,
2006,2006,2007,2007,2007,2008,2008,2008,2008,2008,
2008,2008,2008,2009,2009,2009,2009,2010,2010,2010,
2010,2011,2011,2011,2011,2011,2011,2011,2011,2011,
2012,2012,2012,2012,2013,2013,2013,2013,2014,2014,
2014,2014,2015,2015,2015,2015,2015,2015,2015,2015,
2016,2016,2016,2016,2017,2017,2017,2017,2018,2018,
2018,2018,2019,2019,2019,2019,2019,2019,2019,2019,
2020,2020,2020,2020,2021,2021,2021,2021,2021,2021,
2021,2021,2022,2022,2022,2022,2023,2023,2023,2023,
2024,2024,2024,2024,2025,2025,2025,2025,2026,2026,
2026,2026,2027,2027,2027,2027,2027,2027,2027,2027,
2028,2028,2028,2028,2029,2029,2029,2029,2029,2029,
2029,2029,2030,2030,2030,2030,2031,2031,2031,2031,
2032,2032,2032,2032,2032,2032,2033,2033,2033,2033,
2033,2033,2034,2034,2034,2034,2035,2035,2035,2035,
2036,2036,2036,2036,2037,2037,2037,2037,2037,2037,
2037,2037,2038,2038,2038,2038,2039,2039,2039,2039,
2039,2040,2040,2040,2040,2040,2040,2041,2041,2041,
2041,2041,2042,2042,2042,2042,2042,2042,2042,2043,
2043,2043,2043,2044,2044,2044,2044,2045,2045,2045,
2045,2045,2046,2046,2046,2047,2047,2047 };

#endif
